package arm;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.management.ObjectName;

import org.apache.log4j.Logger;

public class ArmMBeanRespository {

	private static final Logger log = Logger.getLogger(ArmMBeanRespository.class);
	private static ArmMBeanRespository instance = new ArmMBeanRespository();
	
	public static ArmMBeanRespository getInstance()
	{
		if(instance==null)
		{
			instance = new ArmMBeanRespository();
		}
		return instance;
	}
	private ArmMBeanRespository()
	{}
	public static Set respository = new LinkedHashSet();
	
	public void addMBeanToRespository(ObjectName objName) throws Exception
	{
		if(respository.contains(objName))
		{
			throw new Exception("mbean "+objName.getDomain()+" already exist");
		}
		else
		{
			respository.add(objName);
		}
	}
	
	public Set getRespository() {
		return respository;
	}
	
	public void removeMBeanFromRespository(ObjectName objectName)
	{
		if(respository.contains(objectName))
		{
			respository.remove(objectName);
		}
	}
}
